package com.itheiya.mq;

import com.itheiya.constatnts.MqConstants;
import com.itheiya.service.ItermIdexService;
import org.elasticsearch.search.SearchService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *  定义监听器  (监听商品上架, 下架消息)
 */
@Component
public class ItemListener {

    @Autowired
    private ItermIdexService service;

    /**
     * 监听商品新增或修改的消息
     * @param id
     */
    @RabbitListener(queues = MqConstants.HOTEL_INSERT_QUEUE)
    public void listenUpdate(Long id){
        service.insertById(id);
    }

    /**
     * 监听商品删除的消息
     * @param id
     */
    @RabbitListener(queues =  MqConstants.HOTEL_DELETE_QUEUE)
    public void listenDelete(Long id){
        service.deleteById(id);
    }



}

